<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/6
 * Time: 20:55
 */


require_once "../config/database.php";
require_once "adminDb.php";
$AdminDb=new AdminDb();
$task_content=$_POST['task_content'];
$admin=$_POST['user'];
$task_a=$_POST['task_a'];
$date=$_POST['date'];
$userA=$_POST['userA'];
$url=$_POST['url'];
$remarks=$_POST['remarks'];

$addtime=date("Y-m-d",time());
$datea=$AdminDb->selectTask($task_content);
if($datea==null) {
    $data = $AdminDb->addTask($task_content,$admin,$date,$task_a,$userA,$remarks,$url,$addtime);
    try {
        $result = $data;
        if ($result) {
            $dat = array(
                'message' =>"发布成功",
            );
            echo json_encode($dat);

        } else {
            $dat = array(
                'message' =>"发布失败",

            );
            echo json_encode($dat);

        }
    }
    catch (Exception $e) {
        echo $e->getMessage();}

}
else
{

    $dat = array(

        'message' =>"反复提交该任务的操作",

    );
    echo json_encode($dat);


}

